/**
 * 
 */
package mochito.tools.syshook;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


/**
 * @author bin04017
 * 
 */
public class Syshook extends Thread implements KeyboardEventListener {

	private long lastKey = -1;

	private final long key2 = 17; //CTRL

	private final long key1 = 67; //c3
	
	private boolean pressedSinceLastCheck = false;

	public Syshook() {
		KeyboardHook kh = new KeyboardHook();
		kh.addEventListener(this);
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		/*try {
			br.readLine();
		} catch (IOException ex) {
			System.out.println("Error syshook");
		}*/
	}

	public void GlobalKeyPressed(KeyboardEvent event) {
		long actualKey = event.getVirtualKeyCode();
		if (actualKey == key1 && lastKey == key2) {
			pressedSinceLastCheck = true;
		}
		lastKey = actualKey;
	}

	public void GlobalKeyReleased(KeyboardEvent event) {
		// TODO Auto-generated method stub

	}
	
	public boolean getPressedSinceLastCheck(){
		System.out.println("test");
		if(pressedSinceLastCheck == true){
			System.out.println(pressedSinceLastCheck);
			pressedSinceLastCheck = false;
			return true;
		}
		return false;		
	}
}
